# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Thomas Dziedzic <gostrc@gmail.com>
# Contributor: Vesa Kaihlavirta <vesa@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

pkgname=cabal-install
pkgver=3.4.1.0
pkgrel=98
pkgdesc="The command-line interface for Cabal and Hackage."
url="https://hackage.haskell.org/package/cabal-install"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-async' 'haskell-base16-bytestring' 'haskell-cryptohash-sha256'
         'haskell-echo' 'haskell-edit-distance' 'haskell-hackage-security' 'haskell-hashable'
         'haskell-http' 'haskell-network-uri' 'haskell-random' 'haskell-regex-base'
         'haskell-regex-posix' 'haskell-resolv' 'haskell-tar' 'haskell-zlib' 'haskell-lukko')
makedepends=('ghc' 'uusi')
source=("https://hackage.haskell.org/package/cabal-install-${pkgver}/cabal-install-${pkgver}.tar.gz")
sha512sums=('e8a47dc15d65d0da2886c1d936a10648f58b0f29e36c5cc49936e7f5e9d77780956b79432b75717186c2374bdb7251a47801e0478edc481c154d5e5d0d1a70db')

prepare() {
    cd $pkgname-$pkgver
    uusi -u base -u hashable -u HTTP $pkgname.cabal
}

build() {
  cd $pkgname-$pkgver

  runhaskell Setup configure -O --prefix=/usr --enable-executable-dynamic --disable-library-vanilla \
    --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname
  runhaskell Setup build $MAKEFLAGS
}

package() {
  cd $pkgname-$pkgver
  runhaskell Setup copy --destdir="$pkgdir"

  install -Dm644 LICENSE \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  install -Dm644 bash-completion/cabal \
    "${pkgdir}/usr/share/bash-completion/completions/cabal"
}
